load("//bazel:mongo_src_rules.bzl", "idl_generator", "mongo_cc_library")

package(default_visibility = ["//visibility:public"])

exports_files(
    glob([
        "*.h",
        "*.cpp",
    ]),
)

idl_generator(
    name = "type_index_catalog_gen",
    src = "type_index_catalog.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "type_namespace_placement_gen",
    src = "type_namespace_placement.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/s:sharding_types_gen",
    ],
)

idl_generator(
    name = "type_chunk_range_base_gen",
    src = "type_chunk_range_base.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
    ],
)

idl_generator(
    name = "type_chunk_base_gen",
    src = "type_chunk_base.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/s:sharding_types_gen",
    ],
)

idl_generator(
    name = "type_collection_gen",
    src = "type_collection.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/db:keypattern_gen",
        "//src/mongo/s:chunk_version_gen",
        "//src/mongo/s:type_collection_common_types_gen",
        "//src/mongo/s/resharding:type_collection_fields_gen",
    ],
)

idl_generator(
    name = "type_database_gen",
    src = "type_database.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/s:sharding_types_gen",
    ],
)

idl_generator(
    name = "type_remove_shard_event_gen",
    src = "type_remove_shard_event.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
    ],
)

idl_generator(
    name = "type_config_version_gen",
    src = "type_config_version.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
    ],
)

mongo_cc_library(
    name = "sharding_catalog_client",
    srcs = [
        "sharding_catalog_client.cpp",
    ],
    hdrs = [
        "sharding_catalog_client.h",
        "type_namespace_placement_gen",
        "type_shard.h",
        "type_tags.h",
        "//src/mongo/db/commands/query_cmd:bulk_write_crud_op.h",
        "//src/mongo/db/commands/query_cmd:bulk_write_gen",
        "//src/mongo/db/commands/query_cmd:bulk_write_parser.h",
        "//src/mongo/db/pipeline:aggregate_command_gen",
        "//src/mongo/db/pipeline:aggregation_request_helper.h",
        "//src/mongo/db/pipeline:plan_executor_pipeline.h",
        "//src/mongo/db/pipeline:plan_explainer_pipeline.h",
        "//src/mongo/db/query:count_request.h",
        "//src/mongo/db/repl:optime_with.h",
        "//src/mongo/rpc:write_concern_error_detail.h",
        "//src/mongo/s/client:shard.h",
        "//src/mongo/s/client:shard_gen",
        "//src/mongo/s/request_types:placement_history_commands_gen",
        "//src/mongo/s/write_ops:batched_command_request.h",
        "//src/mongo/s/write_ops:batched_command_response.h",
        "//src/mongo/s/write_ops:batched_upsert_detail.h",
    ],
    header_deps = [
        "//src/mongo/bson/mutable:mutable_bson",
        "//src/mongo/db/commands:server_status_core",
    ],
    deps = [
        "//src/mongo/db:keys_collection_document",
        "//src/mongo/db:server_base",
        "//src/mongo/db/exec/document_value",
    ],
)

mongo_cc_library(
    name = "sharding_catalog_client_impl",
    srcs = [
        "sharding_catalog_client_impl.cpp",
    ],
    hdrs = [
        "sharding_catalog_client_impl.h",
        "//src/mongo/db/pipeline:aggregate_command_gen",
    ],
    deps = [
        ":sharding_catalog_client",
        "//src/mongo/db/pipeline",
        "//src/mongo/db/query:projection_ast",
        "//src/mongo/db/repl:read_concern_args",
        "//src/mongo/db/session:logical_session_id_helpers",
        "//src/mongo/db/storage:duplicate_key_error_info",
        "//src/mongo/executor:network_interface",
        "//src/mongo/s:common_s",
        "//src/mongo/s:grid",
        "//src/mongo/s/client:sharding_client",
        "//src/mongo/util:pcre_wrapper",
    ],
)

mongo_cc_library(
    name = "sharding_catalog_client_mock",
    srcs = [
        "sharding_catalog_client_mock.cpp",
    ],
    hdrs = [
        "sharding_catalog_client_mock.h",
    ],
    deps = [
        ":sharding_catalog_client",
        "//src/mongo/s/client:shard_interface",
    ],
)
